<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Rep\ModelNumberRep;
use Illuminate\Http\Request;

class ModelNumber extends Controller
{
    //型号管理
    protected $rep;

    public function __construct(Request $request)
    {
        $this->rep = new ModelNumberRep();
    }

    /**
     * 获取型号列表
     * @param Request $request
     */
    public function getModelNumberList(Request $request){
        $params = $request->all();
        $data = $this->rep->getModelNumberListRep($params);
        return re(0,$data,'success');
    }

    public function addModelNumber(Request $request){
        $params = $request->all();
        $data = $this->rep->addModelNumberRep($params);
        return re($data['code'],$data['data'],$data['msg']);
    }


    /**
     * 产品关联型号
     * @param Request $request
     */
    public function createModelNumber(Request $request){
        $params = $request->all();
        $data = $this->rep->createModelNumberRep($params);
        return re($data['code'],$data['data'],$data['msg']);
    }

    /**
     * 删除型号
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function delModelNumber(Request $request){
        $params = $request->all();
        $data = $this->rep->delModelNumberRep($params);
        return re(0);
    }

    /**
     * 移除关联
     */
    public function delProductModelnumber(Request $request){
        $params = $request->all();
        $data = $this->rep->delProductModelnumberRep($params);
        return re(0);
    }


    /**
     * 批量添加型号
     * @param Request $request
     */
    public function batchAddModelNumber(Request $request){
        $params = $request->all();
        $data = $this->rep->batchAddModelNumberRep($params);
        return re($data['code']);
    }


}
